home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 April: Mac OS SDK / Dev.CD Apr 98 SDK1.toast / Development Kits (Disc 1) / Multiprocessing SDK / Sample Code / MPHelloWorld (Pascal) / sources / MP.p next >
Encoding:
Text File  |  1996-12-09  |  7.1 KB  |  220 lines  |  [TEXT/CWIE]

  1. {This file was processed by Dan's Source Converter}
  2. {version 1.3 (this version modified by Ingemar Ragnemalm)}
  3. {Cleaned up by Matthew Xavier Mora mxmora@apple.com}
  4.  
  5. unit MP;
  6. interface
  7. uses
  8. Types, QuickDraw, Events, Windows, Dialogs, Fonts, DiskInit, TextEdit, Traps,{}
  9. Memory, SegLoad, Scrap, ToolUtils, OSUtils, Menus, Resources, StandardFile,{}
  10. GestaltEqu , Files , Errors , Devices , QuickDrawText , TextUtils,CodeFragments; {}
  11.  
  12. {End of standard head. Add more units to uses as necessary.}
  13.  
  14. (*}
  15. {    MP.h}
  16. {    Version 1.4 (AKA "Developer Release 27")}
  17. {}
  18. {    Header file for the DayStar/Apple Multiprocessing API}
  19. {    Friday, April 5, 1996 6:08:58 PM}
  20. {}
  21. {    !! WARNING !!}
  22. {    NAMES BEGINNING WITH "_MP" ARE NOT YET PART OF THE MP API.}
  23. {    ANY APPLICATION CODE WHICH REFERENCES THESE NAMES IS LIKELY}
  24. {    TO REQUIRE CHANGES WITH NEW RELEASES OF THE MP LIBRARY.}
  25. {*)
  26.  
  27. {ifndef MP_h}
  28. {MP_h=;}
  29.  
  30.  
  31.  
  32.  
  33. {Block of #ifdef __cplusplus skipped here}
  34.  
  35.  
  36. const
  37.         MPCopyrightNotice = 'Copyright © 1995, 1996 DayStar Digital, Inc.Portions Copyright © 1995 Apple Computer, Inc.\n';
  38.  
  39.         MPLibraryName = 'MPLibrary';
  40.         MPLibraryCName = MPLibraryName;
  41.         MPLibraryPName = MPLibraryName;
  42.  
  43.         MP_API_Version = '1.4';
  44.         MPLibrary_MajorVersion = 1;
  45.         MPLibrary_MinorVersion = 4;
  46.         MPLibrary_Release = 0;
  47.         MPLibrary_DevelopmentRevision = 27;
  48.  
  49.  
  50.     type
  51.         Duration = SInt32;
  52.         ByteCount = UInt32;
  53.         MPSemaphoreCount = UInt32;
  54.         MPTaskOptions = UInt32;
  55.  
  56.     type
  57. TaskProc = function (  parameter:univ ptr) : OSStatus;
  58.  
  59.     type
  60.         MPTaskID = longint ;{^_MPTaskID;}
  61.  
  62.         MPQueueID = longint ;{ ^_MPQueueID;}
  63.         MPSemaphoreID = longint ;{ ^_MPSemaphoreID;}
  64.         MPCriticalRegionID = longint ;{^_MPCriticalRegionID;}
  65.  
  66.   MPRemoteProcedure =procedure ( parameter:univ ptr);
  67.  
  68.     _MPPrintfHandler =  procedure ( taskID : MPTaskID; const format:StringPtr ;va:Ptr );    
  69.     const
  70.         NullTaskProc = nil;
  71.         NullMPTaskID = nil;
  72.         NullMPQueueID = nil;
  73.         NullMPSemaphoreID = nil;
  74.         NullMPCriticalRegionID = nil;
  75.         NullMPRemoteProcedure = nil;
  76.         Null_MPPrintfHandler = nil;
  77.  
  78.     const
  79.  
  80.         kMPNoID = nil;
  81.  
  82.         kMPUseDefaultStackSize = 0;
  83.         kMPNormalTaskOptions = 0;
  84.  
  85. { DEBUG: Ingen identifierare för enum }
  86.     const
  87.         kDurationImmediate = 0;
  88.         kDurationForever = $7fffffff;
  89.  
  90.  
  91. {MPErrorValues }
  92.     const
  93.         kMPFirstError = -29299;
  94.  
  95.         kMPInvalidIDErr = kMPFirstError;
  96.         kMPInsufficientResourcesErr = kMPFirstError+1;
  97.         kMPTaskAbortedErr= kMPFirstError+2;
  98.         kMPTimeoutErr= kMPFirstError+3;
  99.         kMPDeletedErr= kMPFirstError+4;
  100.  
  101.         kMPAllocationFailed = kMPInsufficientResourcesErr;
  102.         kMPInvalidTask = kMPInvalidIDErr;
  103.         kMPInvalidQueue = kMPInvalidIDErr;
  104.         kMPInvalidSemaphore = kMPInvalidIDErr;
  105.         kMPInvalidCriticalRegion = kMPInvalidIDErr;
  106.         kMPTaskDeleted = kMPDeletedErr;
  107.         kMPQueueDeleted = kMPDeletedErr;
  108.         kMPSemaphoreDeleted = kMPDeletedErr;
  109.         kMPCriticalRegionDeleted = kMPDeletedErr;
  110.  
  111.         kMPBadEntryPoint = kMPDeletedErr +1;
  112.         kMPUnrecognizedTaskCreationOptions = kMPDeletedErr +2;
  113.         kMPInappropriateStackSize = kMPDeletedErr +3;
  114.         kMPTaskDoesNotOwnCriticalRegion = kMPDeletedErr +4;
  115.         kMPDurationValueNotYetSupported = kMPDeletedErr +5;
  116.         kMPFunctionNotYetImplemented = kMPDeletedErr +6;
  117.         kMPLibraryInternalInconsistencyError = kMPDeletedErr +7;
  118.         kMPTaskSchedulerIsLocked = kMPDeletedErr +8;
  119.  
  120.         kMPFirstUnassignedErrorValue = kMPDeletedErr +9;
  121.  
  122.         kMPLastError = -29250;
  123.  
  124.    function MPCreateTask(entryPoint:TaskProc; parameter:univ ptr;
  125.                stackSize:ByteCount;
  126.                notifyQueue:MPQueueID;
  127.                              terminationParameter1:univ ptr;
  128.                             terminationParameter2:univ ptr ;
  129.                options:MPTaskOptions;
  130.                Var task:MPTaskID):OSStatus;
  131.                
  132.     function MPTerminateTask(task:MPTaskID; terminationStatus:OSStatus):OSStatus;
  133.     function MPCreateQueue(Var queue:MPQueueID):OSStatus;
  134.     function MPNotifyQueue(queue:MPQueueID;         param1:univ ptr;     param2:univ ptr;param3:univ ptr):OSStatus;
  135.     function MPWaitOnQueue(queue:MPQueueID;  param1:Ptr; param2:Ptr;    param3:Ptr;timeout:Duration):OSStatus;
  136.     function MPDeleteQueue(queue:MPQueueID):OSStatus;
  137.     function MPCreateSemaphore(maximumValue:MPSemaphoreCount;  initialValue:MPSemaphoreCount; Var semaphore:MPSemaphoreID):OSStatus;
  138.     function MPSignalSemaphore(semaphore:MPSemaphoreID):OSStatus;
  139.     function MPWaitOnSemaphore(semaphore:MPSemaphoreID; timeout:Duration):OSStatus;
  140.     function MPDeleteSemaphore(semaphore:MPSemaphoreID):OSStatus;
  141.     function MPCreateCriticalRegion(Var criticalRegion:MPCriticalRegionID):OSStatus;
  142.     function MPEnterCriticalRegion(criticalRegion:MPCriticalRegionID; timeout:Duration):OSStatus;
  143.     function MPExitCriticalRegion(criticalRegion:MPCriticalRegionID):OSStatus;
  144.     function MPDeleteCriticalRegion(criticalRegion:MPCriticalRegionID):OSStatus;
  145.  
  146.     function MPCurrentTaskID:MPTaskID;
  147.  
  148.     function MPProcessors:UInt32;
  149.     function _MPInitializationStatus:UInt32;
  150.  
  151.     function _MPIsFullyInitialized:Boolean;
  152.     function _MPLibraryIsCompatible(api:StringPtr; major:UInt32; minor:UInt32; release:UInt32; revision:UInt32):Boolean;
  153.                          
  154.     function _MPTaskIsToolboxSafe(task:MPTaskID):Boolean;
  155.  
  156.  
  157.     function MPAllocate(size:ByteCount):LogicalAddress;
  158.     function _MPAllocateSys(size:ByteCount):LogicalAddress;
  159.  
  160.     procedure MPFree(object:LogicalAddress);
  161.     procedure MPBlockCopy(from:LogicalAddress; toAddr:LogicalAddress; blockSize:ByteCount);
  162.     procedure MPYield;
  163.     procedure MPExit(status:OSStatus);
  164.     procedure _MPLibraryVersion(api:StringPtr;
  165.                     Var major:UInt32;
  166.                     Var minor:UInt32;
  167.                     Var release:UInt32;
  168.                     Var revision:UInt32);
  169.                     
  170.     procedure _MPInitializePrintf(pfn:_MPPrintfHandler);
  171.     procedure _MPPrintf( Var format:char; ...);
  172.     procedure _MPDebugStr(s:StringPtr);
  173.     procedure _MPRPC( procedure MPRemoteProcedure;parameter:univ ptr );
  174.     function _MPStatusPString(status:OSStatus):StringPtr;
  175.     function  MPStatusCString( status:OSStatus):StringPtr;
  176.  
  177. {Block of #ifdef __cplusplus skipped here}
  178.  
  179.  
  180.     function MPCreateBinarySemaphore(semaphore:MPSemaphoreID):OSStatus;
  181.     function MPLibraryIsLoaded: Boolean;
  182.  
  183. implementation
  184.  
  185. {--------------------------------------------------------------------------------------------------}
  186. function MPCreateBinarySemaphore(semaphore:MPSemaphoreID) :OSStatus; 
  187. {--------------------------------------------------------------------------------------------------}
  188. begin
  189.     MPCreateBinarySemaphore:=MPCreateSemaphore(1, 1, semaphore);
  190. end;
  191. {-------------------------------------------------------------}
  192.     function MPLibraryIsLoaded: Boolean;
  193. {-------------------------------------------------------------}
  194.     begin
  195.         MPLibraryIsLoaded:=false;
  196.         if longint(@_MPIsFullyInitialized) <> kUnresolvedCFragSymbolAddress then
  197.             begin
  198.                  MPLibraryIsLoaded:=_MPIsFullyInitialized;
  199.             end; 
  200.     end;
  201.  
  202. {-------------------------------------------------------------}
  203.     function MPLibraryIsCompatible: Boolean;
  204. {-------------------------------------------------------------}
  205.     var
  206.     tempStr:Str255;
  207.     begin
  208.         tempStr:=MP_API_Version;
  209.         
  210.         MPLibraryIsCompatible := _MPLibraryIsCompatible(@tempStr, MPLibrary_MajorVersion, MPLibrary_MinorVersion, MPLibrary_Release, MPLibrary_DevelopmentRevision);
  211.         
  212.     end;
  213.  
  214.  
  215.  
  216. {delete the line above if the file is the main program}
  217.  
  218. {Move it upwards if the unit is not an interface unit.}
  219. end.
  220.